﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
using System.Configuration;
using LightSwitchApplication.UserCode;
namespace LightSwitchApplication
{
    public partial class tlTraingroup
    {
        DateTime TimeFromLast;
        bool firstInitPassed = false;
        partial void TimeFrom_Changed()
        {
            if (!firstInitPassed)
            {
                TimeFromLast = TimeFrom;
                firstInitPassed = true;
                return;
            }

            if (TimeFrom == TimeFromLast)
                return;

            TimeSpan changeDelta = TimeFrom.Subtract(TimeFromLast);
            TimeTo = TimeTo.Add(changeDelta);

            TimeFromLast = TimeFrom;
        }

        partial void TimeTo_Validate(EntityValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Fehlermeldung>");
            if (TimeTo < TimeFrom)
                results.AddPropertyError("Gruppenstart muss vor dem Ende liegen.");

        }
    }
}
